package com.ruoyi.business.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.AppCustomerBill;
import com.ruoyi.business.service.IAppCustomerBillService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客户账单Controller
 * 
 * @author CuiYingJie
 * @date 2020-12-01
 */
@RestController
@RequestMapping("/business/bill")
public class AppCustomerBillController extends BaseController
{
    @Autowired
    private IAppCustomerBillService appCustomerBillService;

    /**
     * 查询客户账单列表
     */
    @PreAuthorize("@ss.hasPermi('business:bill:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppCustomerBill appCustomerBill)
    {
        startPage();
        List<AppCustomerBill> list = appCustomerBillService.selectAppCustomerBillList(appCustomerBill);
        return getDataTable(list);
    }

    /**
     * 导出客户账单列表
     */
    @PreAuthorize("@ss.hasPermi('business:bill:export')")
    @Log(title = "客户账单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AppCustomerBill appCustomerBill)
    {
        List<AppCustomerBill> list = appCustomerBillService.selectAppCustomerBillList(appCustomerBill);
        ExcelUtil<AppCustomerBill> util = new ExcelUtil<AppCustomerBill>(AppCustomerBill.class);
        return util.exportExcel(list, "bill");
    }

    /**
     * 获取客户账单详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:bill:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(appCustomerBillService.selectAppCustomerBillById(id));
    }

    /**
     * 新增客户账单
     */
    @PreAuthorize("@ss.hasPermi('business:bill:add')")
    @Log(title = "客户账单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppCustomerBill appCustomerBill)
    {
        return toAjax(appCustomerBillService.insertAppCustomerBill(appCustomerBill));
    }

    /**
     * 修改客户账单
     */
    @PreAuthorize("@ss.hasPermi('business:bill:edit')")
    @Log(title = "客户账单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppCustomerBill appCustomerBill)
    {
        return toAjax(appCustomerBillService.updateAppCustomerBill(appCustomerBill));
    }

    /**
     * 删除客户账单
     */
    @PreAuthorize("@ss.hasPermi('business:bill:remove')")
    @Log(title = "客户账单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(appCustomerBillService.deleteAppCustomerBillByIds(ids));
    }
}
